package edu.wfu.preparedDishes.user.service.impl;

import edu.wfu.preparedDishes.common.utils.PageUtils;
import edu.wfu.preparedDishes.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import edu.wfu.preparedDishes.user.dao.AddressDao;
import edu.wfu.preparedDishes.user.entity.AddressEntity;
import edu.wfu.preparedDishes.user.service.AddressService;


@Service("addressService")
public class AddressServiceImpl extends ServiceImpl<AddressDao, AddressEntity> implements AddressService {

    @Autowired
   private AddressDao addressDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AddressEntity> page = this.page(
                new Query<AddressEntity>().getPage(params),
                new QueryWrapper<AddressEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 根据用户id查询地址信息
     * @param userId
     * @return
     */
    @Override
    public List<AddressEntity> selectAddressByUserId(String userId) {
       //根据userid查询地址信息
        return addressDao.queryAddressByUserId(userId);
    }

    @Override
    public AddressEntity selectAddressByAddressId(String addressId) {
        return addressDao.queryAddressByAddressId(addressId);
    }

}